﻿using BZOrderPrint.DAL.Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace BZOrderPrint.DAL
{
    public class BZContext : DbContext
    {
        public DbSet<TestEntity> TestEntities { get; set; }
        public DbSet<BzShopEntity> bzShopEntities { get; set; }
        public DbSet<BzOrderEntity> bzOrderEntities { get; set; }
        public DbSet<BzOrderItemEntity> bzOrderItemEntities { get; set; }
        public DbSet<BzWhloeOrderEntity> bzWhloeOrderEntities { get; set; }
        public DbSet<BzYbLineEntity> bzYbLineEntities { get; set; }
        public DbSet<BzUserInfoEntity> bzUserInfoEntities { get; set; }

        public DbSet<TeamOrderItemEntity> teamOrderItemEntities { get; set; }

        public DbSet<BzClientEntity> bzClientEntities { get; set; }

        public BZContext(string ConnectionStringName)
                    : base(ConnectionStringName)
        { }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TestEntity>().ToTable("test").HasKey(k => k.Id);

            modelBuilder.Entity<BzShopEntity>().ToTable("bz_shop").HasKey(k => k.Id);
            modelBuilder.Entity<BzOrderEntity>().ToTable("bz_order").HasKey(k => k.Id);
            modelBuilder.Entity<BzOrderItemEntity>().ToTable("bz_order_item").HasKey(k => k.Id);
            modelBuilder.Entity<BzWhloeOrderEntity>().ToTable("bz_whloe_order").HasKey(k => k.Id);
            modelBuilder.Entity<BzYbLineEntity>().ToTable("bz_yb_line").HasKey(k => k.Id);
            modelBuilder.Entity<TeamOrderItemEntity>().ToTable("team_order_item").HasKey(x => x.Id);
            modelBuilder.Entity<BzUserInfoEntity>().ToTable("bz_user_info").HasKey(x => x.Id);
            modelBuilder.Entity<BzClientEntity>().ToTable("bz_client").HasKey(x => x.Id);
            base.OnModelCreating(modelBuilder);
        }
    }
}
